package com.mongdbtokuduswagger.config;

import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.HashSet;

@Configuration
@EnableSwagger2
@Data
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        HashSet<String> contentType = new HashSet<>(1);
        contentType.add("application/json");
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .consumes(contentType)
                .produces(contentType)
                .select()
                // 扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.mongdbtokuduswagger.controller"))
                .paths(PathSelectors.any())
                .build();
    }


    public ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("mongoToKudu")
                .description("641Mingo同步数据到kudu接口文档")
                .license("Version 1.0")
                .contact("Daft_V")
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
                .version("1.2")
                .build();
    }
}
